package com.easy.controller;

import com.easy.bean.Top_Pattern;
import com.easy.service.Top_PatternService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/top_pattern")
@CrossOrigin
public class Top_PatternController {
    @Autowired
    Top_PatternService top_PatternService;
    @PostMapping
    public Result add(@RequestBody Top_Pattern top_pattern){
        Object obj= top_PatternService.add(top_pattern);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result delete(@PathVariable("id")Integer id){
        Object obj= top_PatternService.del(id);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody Top_Pattern top_pattern){
        Object obj= top_PatternService.edit(top_pattern);
        return Result.success(obj);
    }

    @GetMapping("list")
    public Result list(Top_Pattern top_pattern){
        Object obj= top_PatternService.all(top_pattern);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result select(@PathVariable("id") Integer id){
        Object obj= top_PatternService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Top_Pattern top_pattern){
        top_PatternService.page(page,top_pattern);
        return Result.success(page);
    }


}
